#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n;
    cin>>n;
    vector<int> v(n+1);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    if(v[2]+v[1]==0)
    {
        v[2]=1;
        ans++;
    }
    for(int i=3;i<=n;i++)
    {
        if(v[i-2]+v[i-1]+v[i]<2)
        {
            v[i]=1;
            ans++;
        }
    }
    if(v[n]+v[n-1]==0)ans++;
    cout<<ans;
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}